<template>
  <div  class="app-container calendar-list-container">
    <div style="padding:20px 0">{{$t('setting.Privacy_statement')}}</div>
    <!-- <el-input
      type="textarea"
      placeholder="请输入内容"
      v-model="textarea"
      :autosize="{ minRows: 25, maxRows: 30}"
      class="useContext">
    </el-input> -->
    <vue-editor 
      v-model="textarea"
      @imageAdded="editorUpload"
      useCustomImageHandler />
    <div>    
      <el-button type="primary" class="btn1" @click="changePrivacy">{{$t('setting.Save')}}</el-button>
    </div>
  </div>
</template>

<script>
import { VueEditor } from 'vue2-editor'
import { getSystemParamter , updateSystemParamter,fileUpload } from '@/api/system'
export default {
  name: 'setting_privacy',
  data(){
    return{
      textarea:'',
    }
  },
  components:{
    VueEditor
  },
  methods:{
     //富文本上传图片
    async editorUpload(file, Editor, cursorLocation, resetUploader) {
      if (file.size > 2 * 1024 * 1024) {
        this.$message.warning('图片不能大于2M')
        return
      }
      const formData = new FormData()
      formData.append('file', file)
      formData.append('fileName', 'richtxt')
      const res = await fileUpload(formData)
      Editor.insertEmbed(cursorLocation, 'image', res.data);
      resetUploader();
    },
    async getPrivacy(){
      const{ data } = await getSystemParamter({
        key:'SYS00017',
      })
      this.textarea = data.systemValue
    },
    async changePrivacy(){
      const { data } = await updateSystemParamter({
        key:'SYS00017',
        value:this.textarea
      })
      this.$message({
          type: 'success',
          message: `修改成功!`
        });
      this.getPrivacy();
    },
  },
  created(){
      this.getPrivacy()
  }
}
</script>

<style>
.title{
  padding:30px;
}
.useContext{
  margin-left:30px;
  width:800px;
}
.btn1{
  width: 100px;
  margin:30px;
}
</style>
